package cn.shyouchi.wuguanjia.android.ui.home.security.thread.message.casual;

import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bingoogolapple.photopicker.activity.BGAPhotoPickerPreviewActivity;
import cn.bingoogolapple.photopicker.widget.BGASortableNinePhotoLayout;
import cn.shyouchi.wuguanjia.android.Global;
import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.base.BaseActivity;
import cn.shyouchi.wuguanjia.android.widget.TopBar;

public class ShowCasualActivity extends BaseActivity {

    @BindView(R.id.topBar)
    TopBar mTopBar;
    @BindView(R.id.tv_casual_title)
    TextView mTvCasualTitle;
    @BindView(R.id.tv_casual_content)
    TextView mTvCasualContent;
    @BindView(R.id.photo_snpl)
    BGASortableNinePhotoLayout mPhotoSnpl;
    @BindView(R.id.tv_person)
    TextView mTvPerson;

    CasualNotice mCasualNotice;


    ArrayList<String> imgs = new ArrayList<>();

    @Override
    public int initContentView() {
        return R.layout.activity_show_casual;
    }

    @Override
    public void initInjector() {
        mCasualNotice = getIntent().getParcelableExtra("error");
        if (mCasualNotice != null) {
            for (CasualNotice.ImageBean imageBean : mCasualNotice.getImage()) {
                imgs.add(Global.BASE_URL + imageBean.getImage());
            }
        }
    }

    @Override
    public void initUiAndListener() {
        ButterKnife.bind(this);
        mTopBar.setLeftIcon(R.mipmap.ic_back);
        mTopBar.setTitle(getTitle().toString());
        setSupportActionBar(mTopBar.getToolbar());

        mTvCasualTitle.setText(mCasualNotice.getTitle());
        mTvCasualContent.setText(mCasualNotice.getText());
        mTvPerson.setText(mCasualNotice.getUsername());


        mPhotoSnpl.setDeleteDrawableResId(R.drawable.photo_del_bg);
        mPhotoSnpl.setIsSortable(false);
        mPhotoSnpl.setIsPlusSwitchOpened(false);
        mPhotoSnpl.init(this);
        mPhotoSnpl.setDelegate(new BGASortableNinePhotoLayout.Delegate() {
            @Override
            public void onClickAddNinePhotoItem(BGASortableNinePhotoLayout sortableNinePhotoLayout, View view, int position, ArrayList<String> models) {

            }

            @Override
            public void onClickDeleteNinePhotoItem(BGASortableNinePhotoLayout sortableNinePhotoLayout, View view, int position, String model, ArrayList<String> models) {

            }

            @Override
            public void onClickNinePhotoItem(BGASortableNinePhotoLayout sortableNinePhotoLayout, View view, int position, String model, ArrayList<String> models) {
               startActivity(BGAPhotoPickerPreviewActivity.newIntent(mContext, mPhotoSnpl.getMaxItemCount(), models, models, position, false));
            }
        });

        mPhotoSnpl.setData(imgs);


    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isApplyStatusBarColor() {
        return true;
    }


}
